<template>
  <view style="padding-bottom: 120rpx;">
    <u-cell-group :border="false">
      <u-cell-item title="设计类型" :arrow="false" v-if="!DesignType && (data.ObjectType == 3 || data.ObjectType == 4)">
        <u-radio-group :value="designType" disabled>
          <view class="grid-2">
            <u-radio name="1">店内画面设计</u-radio>
            <u-radio name="2">户外广告</u-radio>
            <u-radio name="3">1+1媒体</u-radio>
          </view>
        </u-radio-group>
      </u-cell-item>

      <template v-else>
        <u-cell-item title="设计类型" :arrow="false" v-if="objectType == 3 || objectType == 4 || objectType == 5">
          <u-checkbox-group @change="handleDesignTypeChange" disabled>
            <view style="padding-left: 30rpx;" v-if="objectType == 3 || objectType == 5">
              <u-checkbox v-model="item.checked" v-for="(item, index) in DesignTypeList" :name="item.value">
                {{ item.label }}
              </u-checkbox>
            </view>

            <view style="padding-left: 30rpx;" v-if="objectType == 4">
              <u-checkbox v-model="item.checked" v-for="(item, index) in DesignTypeList" :name="item.value">
                {{ item.label }}
              </u-checkbox>
            </view>
          </u-checkbox-group>
        </u-cell-item>
      </template>

      <u-cell-item title="设计需求" :arrow="false" :border-bottom="false" style="padding-bottom: 0;"></u-cell-item>
      <u-cell-item :arrow="false" style="padding: 10rpx 10rpx 10rpx 30rpx;">
        <u-input
          placeholder=""
          :customStyle="customStyle"
          :value="data.DealerAuditInfo.Remark"
          :disabled="true"
          inputAlign="left"
          type="textarea"
        ></u-input>
      </u-cell-item>
      <u-cell-item title="现场初始图" :arrow="false" :border-bottom="false" style="padding-bottom: 0;"></u-cell-item>
      <u-cell-item :arrow="false" style="padding: 10rpx;">
        <image-upload :readonly="true" :value="data.InitialPhotoList.filter(item => item.TypeId == 1)"></image-upload>
      </u-cell-item>
      <u-cell-item :arrow="false" style="padding: 10rpx;">
        <file-picker :readonly="true" :value="data.InitialPhotoList.filter(item => item.TypeId == 4)"></file-picker>
      </u-cell-item>

      <block v-if="selectType == 3">
        <u-cell-item title="设计小样图" :arrow="false" :border-bottom="false" style="padding-bottom: 0;"></u-cell-item>
        <u-cell-item :arrow="false" style="padding: 10rpx;">
          <image-upload :readonly="true" :value="data.DesignPhotoList.filter(item => item.TypeId == 1)"></image-upload>
        </u-cell-item>
        <u-cell-item :arrow="false" style="padding: 10rpx;">
          <file-picker :readonly="true" :value="data.DesignPhotoList.filter(item => item.TypeId == 4)"></file-picker>
        </u-cell-item>
      </block>

      <u-cell-item
        title="源文件下载链接"
        :border-bottom="false"
        :arrow="false"
        style="padding-bottom: 0;"
      ></u-cell-item>
      <u-cell-item style="padding: 0 30rpx;" :arrow="false">
        <view
          style="padding: 0 30rpx;"
          class="u-flex u-row-between"
          v-for="(item, index) in data.FileList"
          :key="index"
        >
          <view style="width: 70%;" class="u-line-1 u-text-left">{{ item.JumpUrl }}</view>
          <view style="width: 30%;" class="u-text-left">密码: {{ item.Title }}</view>
        </view>
      </u-cell-item>

      <block v-if="showReview">
        <u-cell-item title="申请时间" :arrow="false" :value="data.DealerAuditInfo.ApplicationDate | date"></u-cell-item>
        <u-cell-item title="申请备注" :arrow="false">
          <u-input
            :customStyle="customStyle"
            :value="data.DealerAuditInfo.ApplicationRemake"
            type="textarea"
            inputAlign="right"
            placeholder=""
            :disabled="true"
          ></u-input>
        </u-cell-item>
        <u-cell-item title="申请状态" :arrow="false" :value="data.DealerAuditInfo.StateName"></u-cell-item>
        <review-flow :data="data.AuditForList"></review-flow>
      </block>
    </u-cell-group>
  </view>
</template>

<script>
export default {
  name: 'design-information',
  props: {
    showReview: {
      type: Boolean,
      default: false
    },
    selectType: {
      type: [Number, String],
      default: 1
    },
    data: {
      type: Object,
      default() {
        return {
          InitialPhotoList: [],
          DesignPhotoList: [],
          FileList: [],
          DealerAuditInfo: {},
          AuditForList: [],
          ObjectType: '',
          DoorPlane: '',
          OutDoorAdvertising: '',
          Media: '',
          DesignTypeList: []
        };
      }
    }
  },

  data() {
    return {
      customStyle: {
        color: '#909399',
        fontSize: '26rpx'
      },
      designType: '',

      DesignType: '',

      objectType: '',
      DesignTypeList: []
    };
  },

  created() {
    if (this.data.DoorPlane > 0) {
      this.designType = 1;
    } else if (this.data.OutDoorAdvertising > 0) {
      this.designType = 2;
    } else if (this.data.Media > 0) {
      this.designType = 3;
    }

    if (this.data.DesignTypeList) {
      this.DesignTypeList = this.data.DesignTypeList.map(item => {
        return {
          label: item.Value,
          value: item.Key,
          checked: false
        };
      });
    }

    if (this.data.DesignType) {
      this.DesignType = this.data.DesignType;

      this.DesignTypeList.forEach(item => {
        if (this.DesignType.split(',').includes(String(item.value))) {
          item.checked = true;
        }
      });
    }

    if (this.data.objectType) {
      this.objectType = this.data.objectType;
    }
  },

  methods: {}
};
</script>

<style lang="scss"></style>
